package com.example.androidpattern.proxy.classes;

import android.util.Log;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @ClassName: DynamicProxy$
 * @Description: 动态代理
 * @Author: xinya
 * @CreateDate: 2020/11/12$ 11:40$
 * @UpdateRemark: 更新内容
 * @Version: 1.0
 */
public class DynamicProxy implements InvocationHandler {
    private static final String TAG = "DynamicProxy";
    private Object mObject;

    public DynamicProxy(Object object) {
        mObject = object;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        Log.d(TAG, "Before invoke: " + method.getName());
        Object result = method.invoke(mObject, args);
        Log.d(TAG, "After invoke: " + method.getName());
        return result;
    }
}
